
a_list2 = []
F = [(1, 0), (0, 1), (-1, 0), (0, -1)]
B = 30

def aa(n, L, j, FN, x, y):
    ff = F[FN % 4]
    # print ff
    for i in range(2 * L):
        n += 1
        x += ff[0] * B
        y += ff[1] * B

        a_list2.append([x, y])
        if i + 1 == L:
            FN += 1
            ff = F[FN % 4]

    FN += 1
    ff = F[FN % 4]
    L += 1

    if j <= n:
        return [x, y]
    else:
        return aa(n, L, j, FN, x, y)


x = 0
y = 0
xx = aa(1, 1, 120, 0, x, y)
print xx
print a_list2
